package com.course.file.controller;

import com.course.file.service.VodService;
import com.course.file.util.VodUtils;
import com.course.server.common.Result;
import com.course.server.dto.FileDto;
import com.course.server.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 阿里云视频点播服务
 *
 * @author: Durian
 * @date: 2021/5/23 10:36
 */
@Validated
@Slf4j
@RestController
public class VodController {

    public static final String BUSINESS_NAME = "视频点播";

    @Resource
    private VodService vodService;


    @PostMapping("/vod")
    public Result uploadVod(@RequestPart MultipartFile shard, FileDto fileDto) throws Exception {
        return Result.success(vodService.upload(shard, fileDto));
    }

    @PostMapping("/vod/check")
    public Result vodCheck(@NotNull FileDto fileDto) throws Exception {
        return Result.success(vodService.check(fileDto));
    }

    @GetMapping("/vod/auth/{vod}")
    public Result getAuth(@PathVariable("vod") String vod) throws Exception {
        return Result.success(vodService.getAuth(vod));
    }
}
